<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!-- <meta name="viewport" content="width=device-width, initial-scale=1.0"> -->
<link rel="stylesheet" href="css/bootstrap.css" />
<link rel="stylesheet" href="css/default.css"/>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/bootstrap.js"></script>
<script type="text/javascript">
	var addFood=function(){
		$.ajax({
			url:"AddFoodServlet？foodname="+$(this).prevUntil("h3").text()+"&num="+$(this).prev().find("input").val(),
			type:"GET",
			success:function(data){
				if(data=="success"){
					alert("添加成功！");
				}else{
					alert("添加失败，请重新添加！");
				}
			}
		});
	}
	function add(obj){
		var val=$(obj).parent().next().val();
		var value=parseInt(val,10);
		$(obj).parent().next().val(value+1);
	}
	function sub(obj){
		var value=$(obj).parent().prev().val();
		if(value>0){
			$(obj).parent().prev().val(value-1);
		}
	}
	
</script>
<title>主界面</title>
</head>
<body>
	<div id="main_contain">
	<div class="col-lg-3 input-lg">
	<ul class="nav nav-pills nav-stacked">
	  <li class="active">
	    <a href="javascript:void(0);" onclick="">
	      <span class="badge pull-right">42</span>
	      素菜
	    </a>
	  </li>
	  <li class="active">
	    <a href="javascript:void(0);">
	      <span class="badge pull-right">42</span>
	      荤菜
	    </a>
	  </li>
	  <li class="active">
	    <a href="javascript:void(0);">
	      <span class="badge pull-right">42</span>
	      汤类
	    </a>
	  </li>
	  <li class="active">
	    <a href="javascript:void(0);">
	      <span class="badge pull-right">42</span>
	      主食
	    </a>
	  </li>
	  
	</ul>
	</div>
	</div>
	
	<div id="main_rightbody">
		
		<div class="row">
		  <div class="col-sm-6 col-md-3">
		    <div class="thumbnail">
		      <img data-src="/LeeSir/images/1.png" alt="菜品说明">
		      <div class="caption">
		        <h3>菜名</h3>
		        <p>菜的简介，价格等信息</p>
				<div class="row">
				  <div class="col-lg-6">
				    <div class="input-group">
				      <span class="input-group-btn">
				        <button class="btn btn-default" onclick="add(this);" type="button">+</button>
				      </span>
				      <input type="text" class="form-control" value="0">
				      <span class="input-group-btn">
				        <button class="btn btn-default" onclick="sub(this);" type="button">-</button>
				      </span>
				    </div>
				  </div>
				</div>
		        <p><a href="javascript:void(0);" onclick="addFood();" class="btn btn-primary" role="button">加入定单</a> <a href="#" class="btn btn-default" role="button">Button</a></p>
		      </div>
		    </div>
		  </div>
	</div>
	</div>
	<button type="button" onclick="location.href='order.jsp'" class="btn btn-success">订单</button>
</body>
</html>